package com.example.demo;

import ch.qos.logback.core.util.StringUtil;
import jakarta.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @RequestMapping("/login")
    public Boolean login(String userName, String password, HttpSession httpSession) {
        if (StringUtil.isNullOrEmpty(userName) || StringUtil.isNullOrEmpty(password)) {
            return false;
        }
        if ("admin".equals(userName) && "123456".equals(password)) {
            httpSession.setAttribute("name", userName);
            return true;
        }
        return false;
    }
}
